package com.easy.project.controller.system;

import cn.dev33.satoken.secure.SaSecureUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.easy.project.base.result.BizResult;
import com.easy.project.constant.SexEnum;
import com.easy.project.domain.dto.system.UserDTO;
import com.easy.project.domain.dto.system.UserEditDTO;
import com.easy.project.domain.vo.system.SysUserInfoVO;
import com.easy.project.domain.vo.system.SysUserVO;
import com.easy.project.service.system.ISysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 系统用户表 前端控制器
 * </p>
 *
 * @author wxz
 * @since 2024-01-10
 */
@RestController
@RequestMapping("/sys-user-po")
@Api(tags = "系统管理-用户管理")
public class SysUserController {

    @Resource
    private ISysUserService sysUserService;

    @GetMapping("/user/page")
    @ApiOperation(value = "用户列表分页")
    public BizResult<IPage<SysUserVO>> userPage(UserDTO userDTO) {
        return BizResult.success(sysUserService.userPage(userDTO));
    }

    @PostMapping("/user/edit")
    @ApiOperation(value = "编辑用户",notes = "编辑用户 有id更新用户 无id新增用户")
    public BizResult<Void> userEdit(@RequestBody @Validated UserEditDTO userEditDTO){
        sysUserService.userEdit(userEditDTO);
        return BizResult.success();
    }

    @GetMapping("/user/info")
    @ApiOperation(value = "用户详情")
    public BizResult<SysUserInfoVO> userInfo(@RequestParam Long id) {
        return BizResult.success(sysUserService.userInfo(id));
    }


}
